home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
dev
/
misc
/
egs.lha
/
EGS
/
EGS_Devels
/
Examples
/
EGS_Requester
/
requester1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-17
|
3KB
|
202 lines
/*
** Author: Markus van Kempen
** Date : 18. Dezember 1992
** 09 Jan 1993 mvk
**
** This example shows how to work with EGS_REQUESTER.
**
** The routines myError, myMSG and EventLoop open
**
** requesters.
**
**
**
** (c) by VIONA-Development 1992/93
**
*/
/*
** Init-Routines
*/
#include "Global.h"
#include "EventLoop.c"
#include "makegadget.c"
/*
**
**
*/
BOOL InitLibraries(struct OpenStructTyp *OS)
{
struct OpenStructTyp *p = &OS[0];
while (p->Base != NULL)
{
if ((*(p->Base) = (ULONG)OpenLibrary(p->Name,p->Version)) == NULL)
{
printf(" Can't open %s version %d",p->Name, p->Version);
return FALSE;
}
else
{ p ++; }
}
return TRUE;
}
/**/
/*
**
**
*/
void CloseLibraries(struct OpenStructTyp *OS)
{
struct OpenStructTyp *p = &OS[0];
while (*(p->Base) != NULL && p->Name != NULL)
{
CloseLibrary((void *)(*(p->Base)));
*(p->Base) = NULL;
p++;
}
}
/**/
/*
** Open a requester in the middle of
** the screen.
**
*/
void myMSG(char *string)
{
if ( string != NULL)
{
if ( EGSRequestBase == NULL)
{
printf("%s\n",string);
}else{
ErrorReq = (ER_SimpleRequestPtr)ER_CreateSimpleRequest(NULL,
(char *)string,(char *)"OK");
/*
** Open requester in the middle of the screen,
**
** if you can!
*/
ErrorReq->Req.Nw->Flags |= EI_WINDOWCENTER;
/*
ErrorReq->Req.Nw->LeftEdge = Window->LeftEdge;
ErrorReq->Req.Nw->TopEdge = Window->TopEdge;
*/
ErrorReq->Req.Title ="Msg Requester";
ER_DoRequest(&(ErrorReq->Req)) ;
}
}
}
/*
* Author: Markus van Kempen
* Date : 9. November 92
*
* This routine is for error handling.
* It closes all open things of the
* program.
*
* if ende == TRUE then myError terminates,
* otherwise it returns
*
*/
void myError(char *string,int ende)
{
myMSG("Hello world !|This is a Requester !");
myMSG(string);
if ( Window != NULL )
EI_CloseWindow(Window);
if ( con != NULL )
EB_DeleteGadContext(con);
if ( FontforMenu != NULL )
EG_CloseFont(FontforMenu);
if ( Menu != NULL )
EI_FreeMenu(Menu);
if ( ErrorReq != NULL )
ER_DeleteRequest(&(ErrorReq->Req));
CloseLibraries(OpenStruct);
if (ende)
exit(0);
}
/**/
/*
** myopen = Opens all egs libraries
** and calls InitMenu from initmenu.c,
** then calls CreateGads from makegadgets.c
**
**
*/
struct EI_Window *myopen(void)
{
struct EI_Window *fenster=NULL;
if ( InitLibraries(OpenStruct) == FALSE)
myError("Can't OpenLibrary",10);
/*
SEE Init_Menu.c
Menu=InitMenu(FontforMenu);
if ( Menu == NULL )
myError("Could not build menu",10);
*/
fenster=CreateGads(NULL);
if (fenster == NULL)
myError("Could not open window",10);
return(fenster);
}
/*
**
** start GUI
**
*/
void main(void)
{
Window=myopen(); /* see myopen.c */
if(Window)
HandleEvents(Window);
myError(NULL,10);
}
/* ENDE */